#include "StdAfx.h"
#include "IOObject.h"
namespace IOFrame
{
	PIOData NewIOData(DWORD dwBufferSzie)
	{
		static SIZE_T size=sizeof(IOData);
		if(0==dwBufferSzie)
		{
			dwBufferSzie=DEFAULT_BUFFERSIZE;
		}
		PIOData ret=(PIOData)::GlobalAlloc(GPTR,size+dwBufferSzie);
		ret->dwBufSize=dwBufferSzie;
		ASSERT(NULL!=ret);
		ResetData(ret);
		return ret;
	}

	void DeleteIOData(PIOData pData)
	{
		::GlobalFree(pData);
	}

	void ResetData( PIOData pData)
	{
		ASSERT(NULL!=pData);
		static SIZE_T size=sizeof(IOData);
		DWORD dwBufSize=pData->dwBufSize;
		ZeroMemory(pData,size+dwBufSize);
		pData->buf=LPBYTE(pData)+size;
		pData->dwBufSize=dwBufSize;
	}
}